/* 
 * 自动完成插件
 */
define(function(require)
{
  var $ = require('jqts');
  $(function()
  {
    $(".jx_main_visual").hover(function(){
		$("#jx_t_btn_prev,#jx_t_btn_next").fadeIn()
    },function(){
      $("#jx_t_btn_prev,#jx_t_btn_next").fadeOut()
    });
	
    $dragBln = false;

    $(".jx_main_image").touchSlider({
      flexible : true,
      speed : 20,
      btn_prev : $("#jx_t_btn_prev"),
      btn_next : $("#jx_t_btn_next"),
      paging : $(".jx_flicking_con a"),
      counter : function (e){
        $(".jx_flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
      }
    });
	
    $(".jx_main_image").bind("mousedown", function() {
      $dragBln = false;
    });

    $(".jx_main_image").bind("dragstart", function() {
      $dragBln = true;
    });
	
    $(".jx_main_image a").click(function(){
      if($dragBln) {
        return false;
      }
    });
	
    timer = setInterval(function(){
      $("#jx_t_btn_next").click();
    }, $(".jx_main_visual").attr("speed"));

    $(".jx_main_visual").hover(function(){
      clearInterval(timer);
    },function(){
      timer = setInterval(function(){
        $("#jx_t_btn_next").click();
      },$(".jx_main_visual").attr("speed"));
    });
	
    $(".jx_main_image").bind("touchstart",function(){
      clearInterval(timer);
    }).bind("touchend", function(){
      timer = setInterval(function(){
        $("#jx_t_btn_next").click();
      }, $(".jx_main_visual").attr("speed"));
    });
    
    var width = $(".jx_main_visual").width() ;
    var h = $(".jx_main_visual").attr("h") ;
    if (undefined != h)
    {
      h = width * h ;
      $(".jx_main_visual").height(h) ;
      $(".jx_main_image").height(h) ;
      $(".jx_main_image ul").height(h) ;
      $(".jx_main_image li").height(h) ;
      $(".jx_main_image li span").height(h) ;
      $(".jx_main_image li a").height(h) ;
    }
  });
})